<template>
  <div>
    <el-table 
                :data="tableData"
                stripe
                class="tableBox">
        <el-table-column prop="title"
                         width="400"
                         label="文章标题" />
        <el-table-column prop="source"
                         label="数据来源" />
        <el-table-column prop="type"        
                         label="分类类型">
          <template slot-scope="scope">
            <span>{{ options[scope.row.category-1].label }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="createTime"
                         label="发布时间" />
        <el-table-column label="操作"
                         align="center">
          <template slot-scope="scope">
            <el-button type="text"
                       size="small"
                       class="blueBug"
                       @click="handleUnFavorite(scope.row.id)">
              取消收藏
            </el-button>
            
          </template>
        </el-table-column>
      </el-table>
  </div>
</template>

<script>
import{getUserFavoriteList,FavoriteOrUnFavorite}from"@/api/article"
export default {
  data(){
    return{
      options: [
    {
      value: 1,
      label: '南疆单列'
    },
    {
      value: 2,
      label: '专项计划'
    },
    {
      value: 3,
      label: '高职单招'
    }
  ],
  tableData:''
    }
 
  },
  methods:{
    handleUnFavorite(id){
      const params={"status":2,"id":id}
      FavoriteOrUnFavorite(params).then(res=>{
        if(res.data.code===1){
          this.$message.success("取消收藏成功")
          getUserFavoriteList().then(res=>{
      if(res.data.code===1){
        this.tableData=res.data.data
      }
    })
        }
      })
    }
  }
  ,
  created(){
    getUserFavoriteList().then(res=>{
      if(res.data.code===1){
        this.tableData=res.data.data
      }
    })
  }

}
</script>

<style>

</style>